loginController.$inject = ['$scope','$location','loginRegisterService'];

var appContext = require('../../../config/app.context');

function loginController($scope, $location, loginRegisterService) {

    $scope.doLogin = function($event) {
        // alert("login..");
        var name = $scope.loginInfo.name;
        var password = $scope.loginInfo.password;

        loginRegisterService.doLogin($scope.loginInfo).then(
            function(response) {
                // alert(JSON.stringify(response.data));
                if (response.data.result) {
                    $location.path(appContext.path + '/home');
                } else {
                    $scope.errorMsg = response.data.errMsg;
                }
            },
            function(err) {
                $scope.errorMsg = 'Connection Failed!';
            }
        );
    }

}
module.exports = loginController;